// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import axios from 'axios'
const myUtils = {
    appRequest: function (config, _this) {

        axios(config).then(function (res) {
            var data = res.data
            console.log('请求地址:' + config.url + ',返回参数:', res)
            if (data.code === '000000') {
                if (config.callback != null) {
                config.callback(data)
                }
            } else if (data.code === '980102') {
                localStorage.removeItem('ltsh_session_user_token')
                _this.$router.push({ path: '/login' })
            } else {
                _this.$message({
                showClose: true,
                message: data.message,
                type: 'error'
                })
                if (config.error != null) {
                config.error(data)
                }
            }
        }).catch(function (error) {
            console.log('httpError', error)
            if (config.catch != null) {
                config.catch(error)
            } else {
                _this.$message({
                showClose: true,
                message: error,
                type: 'error'
                })
            }
        })
    }
    
}
export default myUtils